<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="../../org/angular.min.js"></script>
</head>

<body ng-app="app" ng-controller="ctrl">
    <input type="text" name="" ng-model="title">{{error}}
    <script>
        var m = angular.module('app', []);
        m.controller('ctrl', ['$scope', function($scope) {
            $scope.title = '';
            $scope.$watch('title', function(newData, oldData) {
                $scope.error = $scope.title.length > 3 ? '标题长度不能超过三个' : '';
            })
        }])
    </script>
</body>

</html>
